home *** CD-ROM | disk | FTP | other *** search
- /* patches required for after dark to run */
-
- #include <Traps.h>
- #include "patches.h"
-
- #define kOSEIdentifier 0x61596d6d
-
- typedef struct OSEData {
- OSType signature;
- long fill[2];
- short version;
- } OSEData;
-
- long gGetOSEventLink;
- OSEData gADData;
-
- void InstallPatches(void)
- {
- gADData.signature = 'ADr2';
- gADData.version = 0x200;
- gADData.fill[0] = gADData.fill[1] = 0;
-
- gGetOSEventLink = NGetTrapAddress(_GetOSEvent,OSTrap);
- gGetOSEventLink = (long) StripAddress((Ptr)gGetOSEventLink);
- NSetTrapAddress((long)MyGetOSEvent,_GetOSEvent,OSTrap);
- }
-
-
- void RemovePatches(void)
- {
- NSetTrapAddress((long)gGetOSEventLink,_GetOSEvent,OSTrap);
- }
-
-
- /* GetOSEventPatch */
-
- pascal void MyGetOSEvent(void)
- {
- asm {
- movem.l a2-a3,-(sp) ; save regs
- move.l a5,a2 ; get app a5
- move.l CurrentA5,a5
- move.l gGetOSEventLink,a1 ; get link addr
- move.l a2,a5 ; restore non-app a5
-
- tst.w d0
- bne.s @exit
- cmpi.l #kOSEIdentifier,2(a0)
- bne.s @exit
-
- jsr (a1) ; tail patch (yuk)
- lea gADData,a3
- move.l a3,10(a0)
- move.l (a3),2(a0)
- move.w #0x180,14(a0)
-
- move.l #-1,d0
- movem.l (sp)+,a2-a3 ; restore regs
- rts
-
- @exit movem.l (sp)+,a2-a3 ; restore regs
- jmp (a1) ; jump to link
- }
- }
-